const path = require('path');
const webpack = require('webpack');

// 将 'react', 'react-dom', 'lodash' 打包到 dll/vendors 里
module.exports = {
  mode: 'development', // production
  entry: {
    vendors: ['react', 'react-dom', 'lodash']
  },
  output: {
    filename: '[name].dll.js',  // [name] 变量就是 entry下面的vendors
    path: path.resolve(__dirname, '../dll'),
    // 打包生成一个 vendors.dll.js 文件, 通过全局变量 vendors 暴露出去
    library: '[name]'
  },
  plugins: [
    // 该插件对[name], 即vendors.js库文件进行分析, 分析的结果(第三方模块的映射关系)放在/dll/vendors.manifest.json
    new webpack.DllPlugin({
      name: '[name]',
      path: path.resolve(__dirname, '../dll/[name].manifest.json')
    })
  ]
}